<?php


namespace app\home\controller;
use app\home\model\Option as OptionModel;

use \think\facade\Cache;
use think\Controller;

class Option extends Controller
{
    protected $optionModel;
    public function __construct(OptionModel $optionModel)
    {
        parent::__construct();
        $this->optionModel = $optionModel;
    }

    public function all(){
        $list = Cache::get('option_list');
        if(empty($list)){
            $list = $this->optionModel->select();
            //缓存1个月
            Cache::set('option_list',$list,3600*24*30);
        }
        return json($list);
    }

    public function clear(){
        Cache::rm('option_list');
    }
}